package SquarePackage;

import static org.junit.Assert.*;

import org.junit.BeforeClass;
import org.junit.Test;

public class TemperatureTest {

	private static Temperature st;
	private static Temperature c;
	
	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
		st = new Temperature(0,TemperatureScale.CELSIUS);
		c = new Temperature(0,TemperatureScale.CELSIUS);
	}

	@Test(expected = IllegalArgumentException.class)
	public void testTemperatureNotValidTemperature() {
		Temperature low = new Temperature(-5,TemperatureScale.KELVIN);
		fail("Not a valid temperature value");
	}

	@Test
	public void testGetTemperature() {
		assertEquals(0,st.getTemperature(),0.5);
	}

	@Test
	public void testGetTemperatureScale() {
		assertEquals(TemperatureScale.CELSIUS,st.getTemperatureScale());
	}

	@Test
	public void testCompareToLower() {
		c.setTemperature(-10);
		assertEquals(1,st.compareTo(c));
	}

	@Test
	public void testCompareToHigher() {
		c.setTemperature(10);
		assertEquals(-1,st.compareTo(c));
	}	

	@Test
	public void testCompareToEqual() {
		c.setTemperature(0);
		assertEquals(0,st.compareTo(c));
	}
	
	@Test
	public void testSetTemperatureScale() {
		c.setTemperatureScale(TemperatureScale.KELVIN);
		assertEquals(TemperatureScale.KELVIN,c.getTemperatureScale());
		assertEquals(273.15,c.getTemperature(),0.1);
	}

	@Test
	public void testSetTemperaturePossible() {
		c.setTemperature(10);
		assertEquals(10,c.getTemperature(),0.1);
	}
	
	@Test(expected = IllegalArgumentException.class)
	public void testSetTemperatureTooLow() {
		c.setTemperature(-3000);
		fail("Not a valid temperature value");
	}

}
